﻿using System.Collections.Generic;
using UnityEngine;

namespace FwtUnityEngine
{
    public class AnimatedSprite2D : Sprite2D
    {
        public List<Rect> Frames = new List<Rect>();
        public int CurrentFrame;

        public override void Update()
        {
            CurrentFrame++;
            if (CurrentFrame >= Frames.Count)
                CurrentFrame = 0;

            if (CurrentFrame < Frames.Count)
            {
                var frame = Frames[CurrentFrame];
                TextureCoordinates = frame;
            }

            base.Update();
        }
    }
}
